package com.greenold.Visit.service.impl;

import java.util.List;

import com.greenold.commen.domain.Elder;
import com.greenold.common.utils.DateUtils;
import com.greenold.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.greenold.Visit.mapper.VisitRegistrationMapper;
import com.greenold.Visit.domain.VisitRegistration;
import com.greenold.Visit.service.IVisitRegistrationService;

/**
 * 来访登记Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-10-13
 */
@Service
public class VisitRegistrationServiceImpl implements IVisitRegistrationService 
{
    @Autowired
    private VisitRegistrationMapper visitRegistrationMapper;
    public Elder getElderIdByName(String name)
    {
        return visitRegistrationMapper.getElderIdByName(name);
    }
    /**
     * 查询来访登记
     * 
     * @param id 来访登记主键
     * @return 来访登记
     */
    @Override
    public VisitRegistration selectVisitRegistrationById(Long id)
    {
        return visitRegistrationMapper.selectVisitRegistrationById(id);
    }

    /**
     * 查询来访登记列表
     * 
     * @param visitRegistration 来访登记
     * @return 来访登记
     */
    @Override
    public List<VisitRegistration> selectVisitRegistrationList(VisitRegistration visitRegistration)
    {
        return visitRegistrationMapper.selectVisitRegistrationList(visitRegistration);
    }

    /**
     * 新增来访登记
     * 
     * @param visitRegistration 来访登记
     * @return 结果
     */
    @Override
    public int insertVisitRegistration(VisitRegistration visitRegistration)
    {
        String userName = SecurityUtils.getUsername();
        visitRegistration.setCreator(userName);
        visitRegistration.setCreateTime(DateUtils.getNowDate());
        return visitRegistrationMapper.insertVisitRegistration(visitRegistration);
    }

    /**
     * 修改来访登记
     * 
     * @param visitRegistration 来访登记
     * @return 结果
     */
    @Override
    public int updateVisitRegistration(VisitRegistration visitRegistration)
    {
        return visitRegistrationMapper.updateVisitRegistration(visitRegistration);
    }

    /**
     * 批量删除来访登记
     * 
     * @param ids 需要删除的来访登记主键
     * @return 结果
     */
    @Override
    public int deleteVisitRegistrationByIds(Long[] ids)
    {
        return visitRegistrationMapper.deleteVisitRegistrationByIds(ids);
    }

    /**
     * 删除来访登记信息
     * 
     * @param id 来访登记主键
     * @return 结果
     */
    @Override
    public int deleteVisitRegistrationById(Long id)
    {
        return visitRegistrationMapper.deleteVisitRegistrationById(id);
    }
}
